Skip to content

Conversation

ckyrouac
Copy link
Collaborator

@ckyrouac ckyrouac commented Sep 5, 2025

This is a rebased version of #1389 with some fixes on top to make bootc install reset --experimental work with the latest soft reboot code. I'd like to get this in hidden behind --experimental, then iterate on it. I plan to add some e2e tests as a followup but I can work on including them as part of this PR if you want.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new experimental bootc install reset command, which appears to function as a factory reset. The implementation is well-structured, refactoring existing deployment logic to use a new MergeState enum, which is a clean way to handle different deployment sources. The changes also include new utilities for managing stateroots. I've found a couple of issues that need to be addressed before merging.

@cgwalters
Copy link
Collaborator

I think we'll want tests at least before merging, and supporting that with tmt is probably going to be an excellent driver for the feature.

I haven't dug in but I think tmt is relying on injecting ssh keys w/cloud-init, so it might Just Work to do a reset there?

@ckyrouac ckyrouac marked this pull request as draft September 8, 2025 12:52
@ckyrouac ckyrouac force-pushed the factory-reset branch 4 times, most recently from 209e3c0 to b45e272 Compare September 23, 2025 19:36
cgwalters and others added 3 commits September 24, 2025 09:37
This is a nondestructive variant of `to-existing-root`.

Signed-off-by: Colin Walters <[email protected]>
Also cleans up some bugs from rebasing previous commits.
@ckyrouac ckyrouac marked this pull request as ready for review September 24, 2025 15:02
@bootc-bot bootc-bot bot requested a review from jeckersb September 24, 2025 15:02
@ckyrouac
Copy link
Collaborator Author

I think we'll want tests at least before merging

Updated with a basic test.

This is currently used to signal to `bootc status` that the deployment
is a factory reset and doesn't support soft reboot. Otherwise, the soft
reboot code will throw an exception due to mismatched kargs.

Signed-off-by: ckyrouac <[email protected]>
let deployment_dir = ostree.deployment_dirpath(&staged);
let deployment_dir = std::path::Path::new(deployment_dir.as_str());
if deployment_dir.exists() {
let marker_path = deployment_dir.join(".bootc-factory-reset");
Copy link
Collaborator

@cgwalters cgwalters Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have clear const for things like this with an explanation there.

But backing up a second, in the ostree side we have "deployment backing" directories already where we can put metadata.

Though of course we should also be thinking about how this would work with the composefs backend.

Hmmm hmm. Here's an idea, how about we use the deployment's etc directory for state like this instead? I think we could save e.g. system.bootc.merged_from xattr or so?

Basically I lean towards extended attributes over "stamp files" for metadata.

BTW though do note the intersection here with etc.transient - I wonder if we should make that more visible in status output too. If that's enabled each upgrade is already like a reset of /etc.

let deployment_dir = sysroot.deployment_dirpath(deployment);
let deployment_dir = std::path::Path::new(deployment_dir.as_str());
let is_factory_reset =
deployment_dir.exists() && deployment_dir.join(".bootc-factory-reset").exists();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we want a const that is shared

if is_factory_reset {
// Factory reset deployments don't support soft reboots
// this is primarily because the kargs validation will fail when checking for soft reboot
// compatibility in the ostree code, which will cause bootc status and upgrade to fail.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we need to special case this. Why is bootc status failing exactly?

If we're changing (usually dropping) kernel arguments won't the existing karg check work?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a followup - we talked about this in a live chat and there seems to be a libostree bug here where the staged deployment is missing ostree= and that trips an assertion in the soft reboot checks.

Ideally we root cause and fix that.

But we may be able to work around this by detecting when there's no kargs in the staged deployment?

@jlebon
Copy link
Contributor

jlebon commented Oct 7, 2025

Just saw the demo for this. A few random thoughts.

It'd be nice to be able to have different reset levels. One is just resetting /etc. This doesn't require a new stateroot. Another would be resetting both /etc and /var.

Should this use stateroots at all? This would be another thing to implement in the composefs backend (or maybe that code and concept already exist there?). But also it's quite common for /var or subdirectories of /var to be mounts. I.e. the stateroot var is not used in that case. We should probably detect this and error out.

One alternative though is basically to just move everything in /var into /var/.previous. That would work in both cases, is cheap, and makes access to the previous /var trivial.

(There's still the case of submounts in /var of course. We could apply that rename strategy recursively, or just warn and leave it up to the user -- or require them to be unmounted before proceeding?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants